package com.example.pilipili.config;

import com.example.pilipili.interceptor.SessionInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new SessionInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/covers/**",  "/video/**", "/avers/**",// 静态
                        "/user/register","/user/login", // 用户登陆注册
                        "/admins/register","/admins/login", // 管理员登陆注册
                        "/tags" ,
                        "/videos/t","/videos/detail/**","/videos/liket", // 游客视频获取
                        "/comments/v/**"); // 视频评论获取
    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/covers/**" )
                .addResourceLocations("file:E:/pilipili/covers/" );
        registry.addResourceHandler("/video/**" )
                .addResourceLocations("file:E:/pilipili/video/" );
        registry.addResourceHandler("/avers/**" )
                .addResourceLocations("file:E:/pilipili/avers/" );
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
